package cn.sxt.userscenter.outer.service.impl;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;

import cn.sxt.common.userscenter.util.ConstantFinalUtil;
import cn.sxt.common.userscenter.util.DateFormatUtil;
import cn.sxt.userscenter.outer.service.IOuterService;
@Service("outerService")
public class OuterServiceImpl implements IOuterService{
	@Resource
	private DateFormatUtil dateFormatUtil;
	@Override
	public JSONObject verifyUsersTokenService(JSONObject reqJson) {
		JSONObject resultJson = new JSONObject();
		/* 取出token */
		JSONObject dataJson = reqJson.getJSONObject("data");
		String token = dataJson.getString("token");
		JSONObject usersJson = ConstantFinalUtil.TOKEN_MAP.get(token);
		if(usersJson !=null){
			/* 验证token是否有效得到时候更新一下验证时间 */
			usersJson.put("verifyDate", this.dateFormatUtil.formatDateTime(new Date()));
			JSONObject dataResJson = new JSONObject();
			dataResJson.put("users", usersJson);
			resultJson.put("data", dataResJson);
			resultJson.put("code", "1");
			resultJson.put("info", ConstantFinalUtil.INFO_JSON.get("1"));
		}else{
			/* 没有渠道结果 */
			resultJson.put("code", "5");
			resultJson.put("info", ConstantFinalUtil.INFO_JSON.get("5"));
		}
		return resultJson;
	}

}
